// TestIEDlg.h : header file
//

#pragma once
#include "afxwin.h"
#include <cmath>
#include <vector>

template<class T>
double
Distance( T* vec1, T* vec2, int dim )
{
	double dist=0;
	for ( int i=0 ; i<dim ; i++ )
	{
		dist += pow( vec1[i] - vec2[i], 2 );
	}

	return sqrt( dist );
}



// CTestIEDlg dialog
class CTestIEDlg : public CDialog
{
// Construction
public:
	CTestIEDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_TESTIE_DIALOG };
	enum ELanguage { ENGLISH, SPANISH, FRENCH, ITALIAN };

public:

	// Method members
	afx_msg void OnBnClickedBtnOpFile();
	afx_msg void OnEnChangeEdtFilename();

	afx_msg void 
	OnBnClickedBtnDetect();

	// Object members
	CEdit m_edFileName;


// Implementation
protected:
	// Method members
	virtual void 
	DoDataExchange(CDataExchange* pDX);	// DDX/DDV support

	// Generated message map functions
	virtual BOOL 
	OnInitDialog();

	afx_msg void 
	OnSysCommand(UINT nID, LPARAM lParam);

	afx_msg void 
	OnPaint();

	afx_msg HCURSOR 
	OnQueryDragIcon();

	DECLARE_MESSAGE_MAP()

	void
	initializeStatisticalTables();

	void 
	ShowResults( double distancies[], int counter );

	double
	getProbability( double a );


	double
	getFreq( char c, ELanguage lang );

	// Object members
	HICON m_hIcon;

	static double s_letterFreqs[4][30];
	// s_letterFreqs[0][] -> English
	// s_letterFreqs[1][] -> Spanish
	// s_letterFreqs[2][] -> French
	// s_letterFreqs[3][] -> Italian

public:
	CStatic m_stEng;
	CStatic m_stSpa;
	CStatic m_stFr;
	CStatic m_stIta;
	CStatic m_stEngProb;
	CStatic m_stSpaProb;
	CStatic m_stFrProb;
	CStatic m_stItaProb;
	CStatic m_stEngCorrProb;
	CStatic m_stSpaCorrProb;
	CStatic m_stFrCorrProb;
	CStatic m_stItaCorrProb;
	CButton m_chkStructured;
};
